package com.heima.feign;

import com.heima.dto.ApAuthor;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.dtos.AuthorDto;
import com.heima.model.media.dtos.WmNewsResultDTO;
import com.heima.model.wemedia.dto.ArticleCommentManagementVO;
import com.heima.model.wemedia.dto.CommentManagementQueryDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(name = "leadnews-article")
public interface ApArticleFeignClient {

    @PostMapping("/api/v1/author/save")
    public Integer createAuthor(@RequestBody AuthorDto dto);

    @PostMapping("/api/v1/article/save")
    Long createArticle(@RequestBody WmNewsResultDTO dto);

    @GetMapping("/api/v1/article/findByPage")
    List<ArticleDto> findByPage(@RequestParam("page") int page, @RequestParam("size") int size);

    @GetMapping("/api/v1/article/findById/{id}")
    ArticleDto findById(@PathVariable("id") Long id);

    @GetMapping("/api/v1/article/findByWmNewsId/{wmNewsId}")
    ArticleDto findByWmNewsId(@PathVariable("wmNewsId") Integer wmNewsId);

    @DeleteMapping("/api/v1/article/delArticle")
    void delArticleByNewsId(@RequestParam("wmUserId") Integer wmUserId,
                            @RequestParam("wmNewsId") Integer wmNewsId);

    /**
     * 通过userId拿到文章作者
     *
     * @param userId
     * @return
     */
    @GetMapping("/api/v1/author/getAuthorByUserId")
    ApAuthor getAuthorByUserId(@RequestParam("id") Integer userId);

    @GetMapping("/api/v1/author/findById/{id}")
    AuthorDto authorDtoFindById(@PathVariable("id") Integer id);

    /**
     * 通过WmuserId拿到文章评论信息
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/article/find_news_comments")
    public List<ArticleCommentManagementVO> findNewsComments(@RequestBody CommentManagementQueryDTO dto);

    @PostMapping("/api/v1/article/find_wmuserId")
    public Integer findWmNewsIdByArticleId(@RequestBody Long id);
    @PostMapping("/api/v1/article/update_article_enableComment")
    void updateArticleEnableComment(@RequestBody ArticleDto articleDto);
}

